<template>
	<view></view>
</template>

<script>
export default {
	data() {
		return {
			code: ''
		};
	},
	onLoad(e) {
		// #ifdef H5
		this.code = e.yxylCode;
		// #endif
		// #ifdef MP-WEIXIN
		var launchOptions = wx.getLaunchOptionsSync();
		if (launchOptions && launchOptions.referrerInfo && launchOptions.referrerInfo.extraData && launchOptions.referrerInfo.extraData.yxylCode) {
			this.code = launchOptions.referrerInfo.extraData.yxylCode;
		}
		// #endif
		this.exchange();
	},
	methods: {
		exchange() {
			if (this.code) {
				this.$http
					.request({
						url: 'api/UcenterApi/ExchangeCodeAutoNew',
						method: 'POST',
						data: this.code
					})
					.finally(() => {
						uni.switchTab({
							url: '../index/index'
						});
					});
			} else {
				uni.switchTab({
					url: '../index/index'
				});
			}
		}
	}
};
</script>

<style></style>
